<template>
  <el-table :data="list" border style="width: 100%">
    <el-table-column prop="name" label="岗位名称" />
    <el-table-column prop="type" label="角色">
      <template slot-scope="{ row }">
        <span>{{ getPostName(row.type) }}</span>
      </template>
    </el-table-column>
    <el-table-column prop="name" label="岗位类型" />
    <el-table-column label="操作" width="200px" align="center">>
      <template slot-scope="{ row }">
        <el-button type="primary" plain size="mini" @click="edit(row)">编辑</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>
<script>
import { jobList } from "../const";
import { broadcast } from "@/utils/util";
export default {
  name: "PostTable",
  props: {
    list: {
      type: Array,
      default: () => [],
    },
  },
  methods: {
    edit(row) {
      // this.$router.push({
      //   name: "PostCreate",
      //   params: {
      //     row: JSON.stringify(row),
      //     type: "edit",
      //   },
      // });
      let params = {...row}
      //params.type = 'edit'
      broadcast("look.user.post", { type: "edit", data: params });
    },
    getPostName(type) {
      return jobList.find(({ value }) => value === type)?.label;
    },
  },
};
</script>
